<!doctype html>
<html>
<head>
<meta charset="utf-8">


<link href="../../css/joborder.css" rel='stylesheet' type='text/css'>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="../tinymce/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    selector: "textarea"
 });
</script>
<?php


include('../../php/db.php');
$getvariable =  $_GET['refid'];

echo $getvariable;

$getid = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `refid` = '$getvariable' ") or die(mysql_error());
while($rowshow = mysql_fetch_array($getid))
{
	$getemid = $rowshow['employer_id'];
}


$gettitle = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$gettitle2 = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);

$getcat = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getsubcat = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getmined = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getyoe = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getdesc = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getreq = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getcdate = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getapp = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getcredate = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `Employer_ID` = '$getemid' AND `refid` = '$getvariable' ") or die(mysql_error);


$getcname = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getcname2 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getcname3 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);

$getrow2 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getrow3 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getrow4 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow5 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow6 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow7 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow8 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow9 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow10 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);

$refidget = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);


while($row = mysql_fetch_array($getcname))
{
  $clogo = $row['logo'];
  $ccover = $row['cover'];
}


$logo = empty($clogo) ? DEFAULT_LOGO : IMAGE_URL_SMALL.$clogo; 
$cover = empty($ccover) ? DEFAULT_COVER : IMAGE_URL_SMALL.$ccover;

?>

        
        
<title>
<?php  while ($cols1 = mysql_fetch_array($gettitle)) {                                            echo $cols1['Title'];                                    		echo " @ ";									}  ?>
<?php  while ($rowename = mysql_fetch_array($getcname3)) {						 echo $rowename['ename'];    				}  ?>
</title>      
</head>
<body>

<div class="h-top">
<div class="h-top-logo">

<a href="#"> <img src="../../images/handlogo.png" height="50"> </a>
 
</div>
<!-- STARTS HERE -->
<?php if($_SESSION['level'] == 2) { ?>
<div id="nav">
            <div id="nav_wrapper">
                <ul>
                    <li><p>STATUS: </p>
                    </li>
                    <li><?php $getstatus = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `refid` = '$getvariable'");
                        while ($xd = mysql_fetch_array($getstatus)) {
                         $numbstatus =  $xd['status'];
                        }
                        switch ($numbstatus) {
                            case '1':
                                echo "<font color='green'> ACCEPTED </font> ";
                                break;
                            
                            case '3':
                                echo "<font color='cyan'> WAITING </font> ";
                                break;
                            case '2':
                                echo "<font color='red'> Declined </font> ";
                                break;
							case '4':
								echo "<font color='black'> CLOSED </font> ";
                        		break;
						}	
                    ?>
                    </li>
                
                </ul>
            </div>
    <!-- Nav wrapper end -->
</div>
<!-- Nav end -->
<?php } ?>
<!-- ends here -->
</div>

<div class="b-sub-container">
	<div class="b-content">
    	<div class="b-image-upload">
            <img id="companyCover" width = "945px" height = "250px" src="<?=$cover?>"/> 
        	<div class="b-image-button">
     		</div>
     	</div>
	<div class="b-sub-content">
        <div class="b-company-logo">
				<img id="companyLogo" width = "150" height = "150" src="<?=$logo?>"/>
    	</div>
		<div class="b-company-name-container">
    		<div class="b-company-name" >
        		<div  style="font-size:18px; margin-left:10px;" name="companyname">
					 <?php  while ($cols_name = mysql_fetch_array($gettitle2)) {
                                            echo $cols_name['Title'];
                                    		echo "<br>";
									}  ?>
                    
					<?php  while ($row_name = mysql_fetch_array($getcname2)) {
						 $ccname = $row_name['ename'];
						 
    				}  ?>
                    <?php 
					while($rowgetme = mysql_fetch_array($refidget))
						{
							$refid = $rowgetme['refid'];
						}

						 echo "<a href='../View/view.php?refid=$refid' target='new'>";
						 echo $ccname; 
						 echo "</a>";
					?> 
                </div> 
        	</div>
		</div>
        <div class="b-company-overview-container">
        	<div class="b-company-overview">
        		<div class="b-company-overview-content">
					<div  class="b-company-overview-title" name="companyoverview"> Company Overview </div>
        				<div class="b-company-overview-context" name="companyoverviewcontext"> 
                    		<?php  while ($row2 = mysql_fetch_array($getrow2)) {
			 						echo $row2['description'];
    						}  ?>
                    	</div>
                </div>
            </div>
        </div>
        <div class="b-company-why-container">
        	<div class="b-company-why">
        		<div class="b-company-why-content">
                	<div class="b-company-why-title" name="companywhy"> Why Join Us </div>
        			<div class="b-company-why-context" name="companywhycontext">
                    		<?php  while ($row3 = mysql_fetch_array($getrow3)) {
			 						echo $row3['whyjoinus'];
    						}  ?>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="job-description-container">
        	<div class="job-description">
            	<div class="job-description-content">
                	<div class="job-description-title"> Job Description </div>
				    <div class="job-description-context">
                        <?php  while ($cols6 = mysql_fetch_array($getdesc)) {
			 						echo $cols6['Job_description'];
    						}  ?>
                    </div>
        		</div>
            </div>
        </div>
        <div class="job-requirements-container">
        	<div class="job-requirements">
            	<div class="job-requirements-content">
                	<div class="job-requirements-title"> Job Requirements </div>
					<div class="job-requirements-context">
						<?php  while ($cols7 = mysql_fetch_array($getreq)) {
                                                    echo $cols7['Job_requirements'];
                                            }  ?>
                    </div>
               </div>
           </div>
        </div>
      	<!-- <div>
        
        </div>
        <div>
        <?php  while ($cols9 = mysql_fetch_array($getapp)) {
			 						$cneed = $cols9['numapps'];
    						}  ?>
        </div>
        -->
    
    </div>
    
    
    <div class="b-company-right">
    	
        <div class="b-company-snap-container">
			<div class="b-company-snap">
            	<div class="b-company-snap-content">
                	<div  style="font-size:18px; margin-left:10px;" name="companysnap"> Company Snapshot </div>
                    	<div class="tstyle">
                        <table height="250">
                        <tr>
                        <td>Registration No: </td>
                        <td><?php  while ($row4 = mysql_fetch_array($getrow4)) {
						 echo $row4['Registration_No'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Industry: </td>
                        <td><?php  while ($row5 = mysql_fetch_array($getrow5)) {
						 echo $row5['Industry'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Company Size: </td>
                        <td><?php  while ($row6 = mysql_fetch_array($getrow6)) {
						 echo $row6['Company_size'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Working Hours: </td>
                        <td><?php  while ($row7 = mysql_fetch_array($getrow7)) {
						 echo $row7['Working_hours'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Dress Code: </td>
                        <td><?php  while ($row8 = mysql_fetch_array($getrow8)) {
						 echo $row8['Dresscode'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Benefits </td>
                        <td><?php  while ($row9 = mysql_fetch_array($getrow9)) {
						 echo $row9['Benefits'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Spoken Language(s): </td>
                        <td><?php  while ($row10 = mysql_fetch_array($getrow10)) {
						 echo $row10['Spoken_language'];
    				}  ?>  </td>
                        </tr>


                        </table>
                        </div>
                </div>
            </div>
        </div>
        
       <div class="b-job-category-container">
			<div class="b-job-category">
            	<div class="b-job-category-content">
                	<div  style="font-size:18px; margin-left:10px;" name="companycategory"> Job Category</div>
                    	<div class="tstyle">
                  <table>
                  <tr>
                  <td> Main Category: </td>
                  <td>      
        <?php  while ($cols2 = mysql_fetch_array($getcat)) {
			 		echo $cols2['Job_category'];
    					}
		//$catarray = mysql_query("SELECT * FROM `flss`.`job_category` WHERE `Category_ID` = '$catid'") or die(mysql_error());
			//		while ($catshow = mysql_fetch_array($catarray)){
				
				//	echo $catshow['Jobs_Name'];
						
					//	}
					  ?>
                 </td>
                 </tr>
                 <tr>
                 <td> Sub Category: </td>
                 <td>
					<?php  while ($cols3 = mysql_fetch_array($getsubcat)) {
                                echo  $cols3['Job_sub'];
                                        }  
                                        
                        //$subcatarray = mysql_query("SELECT * FROM `flss`.`job_sub` WHERE `Category_ID` = '$catid' AND `sub_no` = '$subcatid'") or die(mysql_error());
                         //       while ($subcatshow = mysql_fetch_array($subcatarray)){
                            
                          //      echo $subcatshow['sub_job'];
                                    
                           //         }
                                  ?>
                 </td>
                 </tr>
                 <tr>       
        		 <td> Minimum Education: </td>
				 <td>	
					<?php  while ($cols4 = mysql_fetch_array($getmined)) {
			 						echo  $cols4['Job_mined'];
    						}  
							
					//$minedarray = mysql_query("SELECT * FROM `flss`.`educ_attainment` WHERE `educ_level` = '$minedid'") or die(mysql_error());
					//while ($minedshow = mysql_fetch_array($minedarray)){
				
			//		echo $minedshow['descirption'];
						
				//		}			
							?>
        		</td>
                </tr>
                <tr>
                <td> Minimum Experience </td>
				<td>
						<?php  while ($cols5 = mysql_fetch_array($getyoe)) {
                                                    $yoeid =  $cols5['Job_yoe'];
                                            }  
                            $yoearray = mysql_query("SELECT * FROM `flss`.`year_experienced` WHERE `yr_ID` = '$yoeid'") or die(mysql_error());
                                    while ($yoeshow = mysql_fetch_array($yoearray)){
                                
                                    echo $yoeshow['ye_level'];
                                        
                                        }
                                            
                                            ?>
				</td>
                </tr>
                </table>        			
                    
                    </div>
                </div>
            </div>
      </div>
       <div class="b-company-map-container">
        	<div class="b-company-map">
               <div class="b-company-map-content">
                <div  style="font-size:18px; margin-left:10px;" name="companyloc"> Company Location </div>	
                <div style="margin-top:10px; margin-left:10px;">
               	<?php 
				$getmap = mysql_fetch_array(mysql_query("SELECT * FROM e_map WHERE employer_id = '$getemid'"));
				echo $getmap['e_address'];
				?>
               </div>
             </div>
        </div>
      </div>
        		  
</div>	
</div>
		
              	<?php if($_SESSION['level'] == '2') { ?>
              <form action="../Candidates.php" method="post" target="new">
              
                     <div class="footerbutton">
                   <input class="button-link" type="submit" name="btnSee" value="See Who Applied">
					</div>
              </form>
              
              	<?php }?>
                <?php if($_SESSION['level'] == '3') { ?>
              <form action='' method="post">
              
                     <div class="footerbutton">
                   <input class="buttons-link" type="submit" name="btnApply" value="Apply Online">
					</div>
              </form>
              
                <?php }?>
                
				<?php if($_SESSION['level'] == NULL) { ?>
              <form action="../../index.php" method="post" target="new">
              
                     <div class="footerbutton">
                   <input class="buttons-link" type="submit" name="btnlogin" value="Login">
					</div>
              </form>
              
              	<?php }?>
                
                
              
		<div class="footerdate">
        	  
              <p style="float:left; margin-top:1px; margin-left:10px;">Date Created: <?php while ($createddate = mysql_fetch_array($getcredate)) {
			 						$credate = $createddate['date_posted'];
									$dtime = new DateTime($credate);
									print $dtime->format("F d, Y");	 } ?> </p> 
              <p style="float:right; margin-top:1px; margin-right:10px;">Date Closing: <?php while ($cols8 = mysql_fetch_array($getcdate)) {
			 						$cdate = $cols8['Job_cdate'];
									$datime = new DateTime($cdate);
									print $datime->format("F d, Y");	}?> </p>
        </div>
        <?php 

        if(isset($_POST['btnSee']))
        {
			header("Location: ../candidates.php");
        }

        if(isset($_POST['btnApply']))
        {
            $login = $_SESSION['login'];
            $appid = mysql_query("SELECT * FROM `flss`.`accounts` WHERE `user` = '$login'");
            while($rowappid = mysql_fetch_array($appid))
            {
                $getappid = $rowappid['account_id'];
            }

            $getjobrefid = $_GET['refid'];
            $getjobid = mysql_query("SELECT * FROM `flss`.`job_order` WHERE `refid` = '$getjobrefid'");
            
            while($rowjobid = mysql_fetch_array($getjobid))
            {
                $getjobid = $rowjobid['job_id'];
            }
            
            $checkapplicant = mysql_query("SELECT count(*) as num FROM `flss`.`job_apply_applicant` WHERE `Job_id` = '$getjobid' AND `Applicant_ID` = '$getappid'");

            if(mysql_fetch_array($checkapplicant)['num'] > 0){
                    echo "<script> alert('You already apply for this Job') </script>";
                

            }

            else if(apply($getjobid, $getappid, "New"))
                {
                    echo "<script> alert('Thank you for applying, we will review your application') </script>";
                }
           

        }
		if(isset($_POST['btnlogin']))
        {
			header("Location:index.php");
        }
        ?>
</div>

        <div class="footer">
        	
            <div style="margin-top:20px; float:left; width:100%;">
            <center>
            
            <p>Copyright @ Famous Labor Supply Service Alright Reserve 2015</p>
            </center>
            </div>
        </div>    




</body>
</html>